#!/usr/bin/python
# -*- coding: UTF-8 -*-

import requests as _request

# 全局 session
_session = _request.Session()

headers = {
    "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
    "Accept-Encoding": "gzip, deflate",
    "Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8",
    "Connection": "keep-alive",
    "Content-Type": "application/x-www-form-urlencoded",
    "Upgrade-Insecure-Requests": "1",
    "User-Agent": "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36"
}


def login():
    data = {
        "username": "admin",
        "password": "123456",
        "submit": "Login"
    }
    url = "http://192.168.1.194:9090/login"
    resp = _session.post(url, data=data, headers=headers)
    print(resp.content)


# login()


def get():
    login()
    url = "http://192.168.1.194:9090/customer/detail?id=7"
    resp = _session.get(url)
    print(resp.content)


def bd():
    url = "https://www.baidu.com/"
    resp = _request.get(url)
    print(resp.content)


if __name__ == "__main__":
    # get()
    bd()
